<template>
  <div>
    <form>
      <n-input v-model:value="data.username"></n-input>
      <n-input v-model:value="data.password"></n-input>
      <n-button @click="submit">登录</n-button>
    </form>
  </div>
</template>
<script setup>
import { signUp } from "@/api/index.js";

const router = useRouter();

const data = reactive({
  username: "",
  password: "",
});

const submit = async () => {
  let res = await signUp(data);
  if (res.code === 200) {
    let token = res.data.token;
    localStorage.setItem("token", token);

    router.replace("/");
  }
};
</script>
<style lang="scss" scoped></style>
